
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.ArrayList,
                 java.util.Iterator,
                 java.util.HashMap,
                 org.apache.struts.util.LabelValueBean,
                 com.scalar.chiptrack.commons.Region,
                 com.scalar.chiptrack.users.forms.UserSetupForm,
                 com.scalar.chiptrack.users.dao.UserDAO,
                 com.scalar.chiptrack.users.User,
                 com.scalar.chiptrack.users.UserGroup,
                 com.scalar.chiptrack.users.Level,
                 com.scalar.chiptrack.users.LevelAccess,
                 com.scalar.chiptrack.users.Functionality,
                 com.scalar.chiptrack.users.FunctionAccess,
                 com.scalar.ScalarException,
                 com.scalar.chiptrack.utils.ConfigManager,
				 com.scalar.chiptrack.utils.StringUtils"%>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/jsp/admin/admin.jsp"/>

<html:html locale="true">

<HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();

 Level level = null;
 //User user = null;
                        %>

<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>

<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js">
</script>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/validations.js">
</script>
<% String valuee = (String)request.getAttribute("ErrorInSaving");
  String regionValue = (String)request.getAttribute("ErrorInRegionSaving");
   String flag1 = request.getParameter("selectflag");
   String flagValue = request.getParameter("flagValue");
   String selecteduser = request.getParameter("createNewUserAsUser");
   String useraction  = request.getParameter("useraction");
    if( useraction == null || "null".equalsIgnoreCase( useraction )){
        useraction = "";
    }
%>

<script language='javascript'>
function loadLevel () {

    if(document.userSetupForm.levelId.value !=-1)
	{
        //alert("Msg:"+document.userSetupForm.messageToUser.value);
		var usernameValue ;
        if( document.userSetupForm.useraction.value == 'saveUserAs')
		{
			if( document.userSetupForm.createNewUserAsUser.value == -1)
			usernameValue = "-1";
			else
			usernameValue = document.userSetupForm.username.value ;
		}
		else  if( document.userSetupForm.useraction.value == 'modify')
		{
			usernameValue = document.userSetupForm.username.value ;
		 }

		else if( document.userSetupForm.createNewUserAsUser.value == -1)
		{
			usernameValue = "-1";
        }
		else if( document.userSetupForm.createNewUserAsUser.value != -1)
		{
			usernameValue = document.userSetupForm.username.value ;
		}

        <%if ( "modify".equalsIgnoreCase( useraction ) ){%>
            formAction = '<%=chipTracContext%>/jsp/admin/user_setup.jsp?level=' + document.userSetupForm.levelId.value + '&username=' +usernameValue + '&useraction=' + document.userSetupForm.useraction.value + '&email=' + document.userSetupForm.email.value + '&userId=' + document.userSetupForm.userId.value + '&groupId=' + document.userSetupForm.userGroupId.value + '&firstName=' + document.userSetupForm.firstName.value + '&lastName=' + document.userSetupForm.lastName.value + '&regionId=' + document.userSetupForm.regionId.value + '&expiresOn=' + document.userSetupForm.expiresOn.value + '&firstName=' + document.userSetupForm.firstName.value + '&lastName=' + document.userSetupForm.lastName.value + '&phoneNumber=' + document.userSetupForm.phoneNumber.value + '&faxNumber=' + document.userSetupForm.faxNumber.value+ '&password=' + document.userSetupForm.password.value+ '&password1=' + document.userSetupForm.password1.value + '&recNotif=' + document.userSetupForm.receiveNotifications.checked + '&salAckMail=' + document.userSetupForm.salesAckMail.checked + '&quoAckMail=' + document.userSetupForm.quoteAckMail.checked + '&shipAlerts=' + document.userSetupForm.shipAlerts.checked + '&rmaAckMail=' + document.userSetupForm.rmaAckMail.checked + '&proformaInv=' + document.userSetupForm.proformaInvoice.checked + '&pacSlip=' + document.userSetupForm.packingSlip.checked;
        <%}else{%>
		    formAction = '<%=chipTracContext%>/jsp/admin/user_setup.jsp?level=' + document.userSetupForm.levelId.value + '&username=' +usernameValue + '&useraction=' + document.userSetupForm.useraction.value + '&email=' + document.userSetupForm.email.value + '&userId=' + document.userSetupForm.userId.value + '&groupId=' + document.userSetupForm.userGroupId.value + '&firstName=' + document.userSetupForm.firstName.value + '&lastName=' + document.userSetupForm.lastName.value + '&regionId=' + document.userSetupForm.regionId.value + '&expiresOn=' + document.userSetupForm.expiresOn.value + '&firstName=' + document.userSetupForm.firstName.value + '&lastName=' + document.userSetupForm.lastName.value + '&phoneNumber=' + document.userSetupForm.phoneNumber.value + '&faxNumber=' + document.userSetupForm.faxNumber.value+ '&password=' + document.userSetupForm.password.value+ '&password1=' + document.userSetupForm.password1.value + '&recNotif=' + document.userSetupForm.receiveNotifications.checked + '&salAckMail=' + document.userSetupForm.salesAckMail.checked + '&quoAckMail=' + document.userSetupForm.quoteAckMail.checked + '&shipAlerts=' + document.userSetupForm.shipAlerts.checked + '&rmaAckMail=' + document.userSetupForm.rmaAckMail.checked + '&proformaInv=' + document.userSetupForm.proformaInvoice.checked + '&pacSlip=' + document.userSetupForm.packingSlip.checked + '&notifyUser=' + document.userSetupForm.notifyUser.checked + '&userMsg='+document.userSetupForm.messageToUser.value;
        <%}%>

        //alert("Msg:"+document.userSetupForm.messageToUser.value);

		document.userSetupForm.action=formAction;
		document.userSetupForm.method='post';
		document.userSetupForm.selectflag.value="1";
		document.userSetupForm.submit();
	}//if
    else
    {
        usernameValue = "-1";
        <%if ( "modify".equalsIgnoreCase( useraction ) ){%>
            formAction = '<%=chipTracContext%>/jsp/admin/user_setup.jsp?level=' + document.userSetupForm.levelId.value + '&username=' +usernameValue + '&useraction=' + document.userSetupForm.useraction.value + '&email=' + document.userSetupForm.email.value + '&userId=' + document.userSetupForm.userId.value + '&groupId=' + document.userSetupForm.userGroupId.value + '&firstName=' + document.userSetupForm.firstName.value + '&lastName=' + document.userSetupForm.lastName.value + '&regionId=' + document.userSetupForm.regionId.value + '&expiresOn=' + document.userSetupForm.expiresOn.value + '&firstName=' + document.userSetupForm.firstName.value + '&lastName=' + document.userSetupForm.lastName.value + '&phoneNumber=' + document.userSetupForm.phoneNumber.value + '&faxNumber=' + document.userSetupForm.faxNumber.value+ '&password=' + document.userSetupForm.password.value+ '&password1=' + document.userSetupForm.password1.value + '&recNotif=' + document.userSetupForm.receiveNotifications.checked + '&salAckMail=' + document.userSetupForm.salesAckMail.checked + '&quoAckMail=' + document.userSetupForm.quoteAckMail.checked + '&shipAlerts=' + document.userSetupForm.shipAlerts.checked + '&rmaAckMail=' + document.userSetupForm.rmaAckMail.checked + '&proformaInv=' + document.userSetupForm.proformaInvoice.checked + '&pacSlip=' + document.userSetupForm.packingSlip.checked;
        <%}else{%>
		    formAction = '<%=chipTracContext%>/jsp/admin/user_setup.jsp?level=' + document.userSetupForm.levelId.value + '&username=' +usernameValue + '&useraction=' + document.userSetupForm.useraction.value + '&email=' + document.userSetupForm.email.value + '&userId=' + document.userSetupForm.userId.value + '&groupId=' + document.userSetupForm.userGroupId.value + '&firstName=' + document.userSetupForm.firstName.value + '&lastName=' + document.userSetupForm.lastName.value + '&regionId=' + document.userSetupForm.regionId.value + '&expiresOn=' + document.userSetupForm.expiresOn.value + '&firstName=' + document.userSetupForm.firstName.value + '&lastName=' + document.userSetupForm.lastName.value + '&phoneNumber=' + document.userSetupForm.phoneNumber.value + '&faxNumber=' + document.userSetupForm.faxNumber.value+ '&password=' + document.userSetupForm.password.value+ '&password1=' + document.userSetupForm.password1.value + '&recNotif=' + document.userSetupForm.receiveNotifications.checked + '&salAckMail=' + document.userSetupForm.salesAckMail.checked + '&quoAckMail=' + document.userSetupForm.quoteAckMail.checked + '&shipAlerts=' + document.userSetupForm.shipAlerts.checked + '&rmaAckMail=' + document.userSetupForm.rmaAckMail.checked + '&proformaInv=' + document.userSetupForm.proformaInvoice.checked + '&pacSlip=' + document.userSetupForm.packingSlip.checked + '&notifyUser=' + document.userSetupForm.notifyUser.checked + '&userMsg='+document.userSetupForm.messageToUser.value;
        <%}%>
		document.userSetupForm.action=formAction;
		document.userSetupForm.method='post';
		document.userSetupForm.selectflag.value="1";
		document.userSetupForm.submit();
    }

}//method

function addNewRegion()
{
     var newRegionabel = document.getElementById("newRegion");
     if (document.userSetupForm.regionId.value == -2 )
     {
        document.userSetupForm.newRegion.style.visibility = "visible";
		document.userSetupForm.newRegion.value = '';
		newRegionabel.innerHTML = "New Region: <font color=red size=1><B> *</B></font>";
        document.userSetupForm.newRegion.focus();
    }
    else
    {
         document.userSetupForm.newRegion.style.visibility = "hidden";
         newRegionabel.innerHTML = "";
    }
}
function check()
{
     var newRegionabel = document.getElementById("newRegion");
      
     if (document.userSetupForm.regionId.value == -2 || document.userSetupForm.newRegion.value.trim().length > 0 )
     {
        document.userSetupForm.regionId.value = -2; 
        document.userSetupForm.newRegion.style.visibility = "visible";
		newRegionabel.innerHTML = "New Region: ";
    }
    else
    {
         document.userSetupForm.newRegion.style.visibility = "hidden";
         newRegionabel.innerHTML = "";
    }
}
function saveUser()
{
	var pa=document.getElementById("errors");
    var pa1=document.getElementById("ErrorMessage");
	var valid = true;
	var region = document.userSetupForm.regionId.value;
	var firstname = document.userSetupForm.firstName.value;
	var lastname = document.userSetupForm.lastName.value;
	var usergroupid = document.userSetupForm.userGroupId.value;
	var mail =  document.userSetupForm.email.value;
	var userid = document.userSetupForm.userId.value;
	var passwd = document.userSetupForm.password.value;
	var passwd1 = document.userSetupForm.password1.value;
	var phone = document.userSetupForm.phoneNumber.value;
	var fax = document.userSetupForm.faxNumber.value;


    var expiresOn = document.userSetupForm.expiresOn.value; //added by Murali Krishna, to validate expires on date

    pa.innerHTML="";
    pa1.innerHTML="";
    if(userid.trim().length == 0)
	{
		valid = false;
		document.userSetupForm.userId.focus();
		pa.innerHTML = "<li> Enter User Id ";
		location="#e1";
	}
	else if(!AlphaNumHyphen(userid,document.userSetupForm.userId,"Y"))
	{
		valid = false;
		document.userSetupForm.userId.focus();
		pa.innerHTML = pa.innerHTML+"<li> User Id should start with alphabets and may contain integers, - , _ only";
		location="#e1";
	}
	else if(!isLetter(userid.substring(0,1)))
	{
		valid = false;
		document.userSetupForm.userId.focus();
		pa.innerHTML = pa.innerHTML+"<li> User Id First charecter must be alphabet only";
		location="#e1";
	}

	if(region == -1)
	{
		valid = false;

		//document.userSetupForm.createNewUserAsUser.focus();
        document.userSetupForm.regionId.focus();
		pa.innerHTML = pa.innerHTML+"<li> Select Region";
		location="#e1";

	}
    if ( region == -2 && document.userSetupForm.newRegion.value.trim().length == 0 )
    {
        valid = false;
        pa.innerHTML = pa.innerHTML+"<li> Enter New Region";
		location="#e1";
        document.userSetupForm.newRegion.focus();
    }
	if(firstname.trim().length == 0)
	{
		valid = false;
		document.userSetupForm.firstName.focus();
		pa.innerHTML = pa.innerHTML+"<li> First Name Required";
		location="#e1";
	}
	else if(!AlphaNum(firstname,document.userSetupForm.firstName,"Y"))
	{
		valid = false;
		document.userSetupForm.firstName.focus();
		pa.innerHTML = pa.innerHTML+"<li> First Name should have alphabets or integers only";
		location="#e1";
	}

	if(usergroupid == -1)
	{
		valid = false;
		document.userSetupForm.userGroupId.focus();
		pa.innerHTML = pa.innerHTML+"<li> Select Group";
		location="#e1";
	}

	if(mail.trim().length = 0)
	{
		valid = false;
		document.userSetupForm.email.focus();
		pa.innerHTML = pa.innerHTML+"<li> Enter Email Id";
		location="#e1";
	}
	else if(!isValidMailID(mail,document.userSetupForm.email,"Y"))
	{
		valid = false;
		document.userSetupForm.email.focus();
		pa.innerHTML = pa.innerHTML+"<li> Enter a valid Email id";
		location="#e1";
	}

	if(passwd.trim().length==0)
	{
		valid = false;
		document.userSetupForm.password.focus();
		pa.innerHTML = pa.innerHTML+"<li> Enter Password";
		location="#e1";
	}
	else if(passwd1.trim().length==0)
	{
		valid = false;
        document.userSetupForm.password1.focus();
		pa.innerHTML = pa.innerHTML+"<li> Enter Confirm Password";
		location="#e1";
	}
	else if( passwd != passwd1 )
	{
		valid = false;
		document.userSetupForm.password.focus();
		pa.innerHTML = pa.innerHTML+"<li> Password and Confirm Password must be same";
		location="#e1";
	}

    <%-- start: Added by Murali Krishna, to validate expires on Date --%>
    if ( chkDate( expiresOn, "Expires on Date", "n") == false )
    {
         valid = false;
         document.userSetupForm.expiresOn.focus();
         pa.innerHTML = pa.innerHTML + errMsg;
    }
    else if ( isBeforeToday( expiresOn.trim(), "Expires on Date" ) )
    {
          valid = false;
          document.userSetupForm.expiresOn.focus();
          pa.innerHTML = pa.innerHTML + errMsg;
    }
    
    <%-- end: Murali Krishna --%>

	if(valid)
	{
		//pa.innerHTML =  "<li> OK fine";
	    document.userSetupForm.submit();
	}

}

function modifyUser() {

	var pa=document.getElementById("errors");
	var valid = true;
	var region = document.userSetupForm.regionId.value;
	var firstname = document.userSetupForm.firstName.value;
	var lastname = document.userSetupForm.lastName.value;
	var usergroupid = document.userSetupForm.userGroupId.value;
	var mail =  document.userSetupForm.email.value;
	var userid = document.userSetupForm.userId.value;
	var passwd = document.userSetupForm.password.value;
	var passwd1 = document.userSetupForm.password1.value;
	var phone = document.userSetupForm.phoneNumber.value;
	var fax = document.userSetupForm.faxNumber.value;
	var date = document.userSetupForm.expiresOn.value;

	pa.innerHTML="";
	if(userid.trim().length == 0)
	{
		valid = false;
		document.userSetupForm.userId.focus();
		pa.innerHTML = "<li> Enter User Id ";
		location="#e1";
	}
	else if(!AlphaNumHyphen(userid,document.userSetupForm.userId,"Y"))
	{
		valid = false;
		document.userSetupForm.userId.focus();
		pa.innerHTML = pa.innerHTML+"<li> User Id should have  alphabets,integers or '- _' only";
		location="#e1"
	}
	else if(!isLetter(userid.substring(0,1)))
	{
		valid = false;
		document.userSetupForm.userId.focus();
		pa.innerHTML = pa.innerHTML+"<li> User Id First charecter must be alphabet only";
		location="#e1"
	}

	if(region == -1)
	{
		valid = false;
		//document.userSetupForm.createNewUserAsUser.focus();
        document.userSetupForm.regionId.focus();
		pa.innerHTML = pa.innerHTML+"<li> Select Region";
		location="#e1"
	}
    if ( region == -2 && document.userSetupForm.newRegion.value.trim().length == 0 )
    {
        valid = false;
        document.userSetupForm.newRegion.focus();
        pa.innerHTML = pa.innerHTML+"<li> Enter New Region";
		location="#e1"
    }
	if(firstname.trim().length == 0)
	{
		valid = false;
		document.userSetupForm.firstName.focus();
		pa.innerHTML = pa.innerHTML+"<li> First Name Required";
		location="#e1"
	}
	else if(!AlphaNum(firstname,document.userSetupForm.firstName,"Y"))
	{
		valid = false;
		document.userSetupForm.firstName.focus();
		pa.innerHTML = pa.innerHTML+"<li> First Name should have  alphabets or integers only";
		location="#e1"
	}

	if(usergroupid == -1)
	{
		valid = false;
		document.userSetupForm.userGroupId.focus();
		pa.innerHTML = pa.innerHTML+"<li> Select Group";
		location="#e1"
	}

	if(mail.trim().length = 0)
	{
		valid = false;
		//document.userSetupForm.email.focus();
		pa.innerHTML = pa.innerHTML+"<li> Enter Email Id";
		location="#e1"
		document.userSetupForm.email.focus();
	}
	else if(!isValidMailID(mail,document.userSetupForm.email,"Y"))
	{
		valid = false;
		//document.userSetupForm.email.focus();
		pa.innerHTML = pa.innerHTML+"<li> Enter a valid Email id";
		location="#e1"
		document.userSetupForm.email.focus();
	}

    <%-- start: Added by Murali Krishna, to validate expires on Date --%>
    if ( chkDate( date, "Expires on Date", "n") == false )
    {
         valid = false;
         document.userSetupForm.expiresOn.focus();
         pa.innerHTML = pa.innerHTML + errMsg;
    }
    else if ( isBeforeToday( date.trim(), "Expires on Date" ) )
    {
          valid = false;
          document.userSetupForm.expiresOn.focus();
          pa.innerHTML = pa.innerHTML + errMsg;
    }
    <%-- end: Murali Krishna --%>



	if(valid)
	{
		//pa.innerHTML =  "<li> OK fine";
	    document.userSetupForm.submit();
	}

}


var dateElement = "";
function openCalendar(dateValue)
{
    dateElement = dateValue;

    newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
    newWindow.moveTo(550,180);
    newWindow.focus();
}

function assignDate(passedValue)
{
    dateElement.value=passedValue;
    window.focus();
}

function loadUserData () {

	var username1 = document.userSetupForm.createNewUserAsUser.value;
	var useraction1 = document.userSetupForm.useraction.value;
	var regionId1 = document.userSetupForm.regionId.value;
	var phoneNumber1 = document.userSetupForm.phoneNumber.value ;
	var faxNumber1 = document.userSetupForm.faxNumber.value;
	var email1 = document.userSetupForm.email.value;
	var passwordd = document.userSetupForm.password.value;
	var passwordd1 = document.userSetupForm.password1.value;
	var userid1 = document.userSetupForm.userId.value;
	var firstname1 = document.userSetupForm.firstName.value;
	var lastname1 = document.userSetupForm.lastName.value;

	if(document.userSetupForm.createNewUserAsUser.value!=-1)
	{
	document.userSetupForm.action='<%=chipTracContext%>/jsp/admin/user_setup.jsp?useraction=saveUserAs&username=' + document.userSetupForm.createNewUserAsUser.value + '&email=' + document.userSetupForm.email.value + '&userId=' + document.userSetupForm.userId.value + '&firstName=' + document.userSetupForm.firstName.value + '&lastName=' + document.userSetupForm.lastName.value + '&regionId=' + document.userSetupForm.regionId.value + '&expiresOn=' + document.userSetupForm.expiresOn.value + '&firstName=' + document.userSetupForm.firstName.value + '&lastName=' + document.userSetupForm.lastName.value + '&phoneNumber=' + document.userSetupForm.phoneNumber.value + '&faxNumber=' + document.userSetupForm.faxNumber.value + '&password=' + document.userSetupForm.password.value+ '&password1=' + document.userSetupForm.password1.value;
	document.userSetupForm.method='post';
	document.userSetupForm.selectflag.value="0";

		if( userid1.length == 0 && regionId1 == -1 && passwordd.length == 0 && passwordd1.length == 0 && firstname1.length == 0 && lastname1.length == 0 && lastname1.length == 0 && email1.length == 0)
		{
			document.userSetupForm.flagValue.value="0";
		}
		else if(regionId1 == -1)
		{
			document.userSetupForm.flagValue.value="0";
		}
		else
		{
			document.userSetupForm.flagValue.value="1";
		}
		document.userSetupForm.submit();
	}//if close

	else if( document.userSetupForm.createNewUserAsUser.value == -1)
	{
        userName = "-1";
		document.userSetupForm.action='<%=chipTracContext%>/jsp/admin/user_setup.jsp?useraction=saveUserAs&username=' + userName + '&email=' + document.userSetupForm.email.value + '&userId=' + document.userSetupForm.userId.value + '&firstName=' + document.userSetupForm.firstName.value + '&lastName=' + document.userSetupForm.lastName.value + '&regionId=' + document.userSetupForm.regionId.value + '&expiresOn=' + document.userSetupForm.expiresOn.value + '&firstName=' + document.userSetupForm.firstName.value + '&lastName=' + document.userSetupForm.lastName.value + '&phoneNumber=' + document.userSetupForm.phoneNumber.value + '&faxNumber=' + document.userSetupForm.faxNumber.value + '&password=' + document.userSetupForm.password.value+ '&password1=' + document.userSetupForm.password1.value;
		document.userSetupForm.method='post';
		document.userSetupForm.selectflag.value="0";

		if( userid1.length == 0 && regionId1 == -1 && passwordd.length == 0 && passwordd1.length == 0 && firstname1.length == 0 && lastname1.length == 0 && lastname1.length == 0 && email1.length == 0)
		{
			document.userSetupForm.flagValue.value="0";
		}
		else if(regionId1 == -1)
		{
			document.userSetupForm.flagValue.value="0";
		}
		else
		{
			document.userSetupForm.flagValue.value="1";
		}
		document.userSetupForm.submit();
   }//elseif

}//method

</script>

<style>
<!--
a.nav:link   { font-family: Verdana,Arial,San Serif; font-size: 10px; text-decoration: none }
a.nav:visited { font-family: Verdana,Arial,San Serif; font-size: 10px; text-decoration: none }
a.nav:active { font-family: Verdana,Arial,San Serif; font-size: 10px; text-decoration: none }
a.nav:hover  { font-family: Verdana,Arial,San Serif; font-size: 10px; text-decoration: none; color: #000000 }
.HEADING     { cursor: hand; font-family: Verdana,Arial,San Serif; font-size: 12px; color: #000000;
               background-color: #FFFFFF; font-weight: none;
               border: 1 solid #000000 }
.LINKSOFF    { display: none; font-family: Verdana,Arial,San Serif; font-size: 12px; color: #000000; }
.LINKSON     { display: inline; font-family: Verdana,Arial,San Serif; font-size: 12px; color: #000000; }
-->
</style>

<Script Language="VBscript">
// Copyright 2001 Stephen Hayes (steve@obtsolutions.co.uk)
// OBT Solutions UK (http://www.obtsolutions.co.uk)
// Permission granted to SimplytheBest.net to feature script in its
// DHTML script collection at http://simplythebest.net/info/dhtml_scripts.html
<!--
Option Explicit
DIM menuID,menuObj,cellBk
SUB ShowHide(menuID)
menuObj = "Link" & menuID
cellbk = "Head" & menuID
// CHECK IF OPEN
if document.all.item(menuObj).className = "LINKSON" then    'IF MENU OPEN THEN CLOSE
document.all.item(menuObj).className = "LINKSOFF"
document.all.item(cellBk).style.backgroundColor = "#FFFFFF"   ' SET CELL BACKGROUND COLOUR BLUE
ELSE
document.all.item(menuObj).className = "LINKSON"               ' OPEN MENU
document.all.item(cellBk).style.backgroundColor = "#FFFFFF"  ' SET CELL BACKGROUND COLOUR RED
END IF
END SUB
-->
</Script>

<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>


<BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0" onload='check();'>

<html:form name="userSetupForm" type="com.scalar.chiptrack.users.forms.UserSetupForm" action="/userSetup.do">
<input type="hidden" name="useraction" value='<%=request.getParameter ("useraction")%>'>
<input type="hidden" name="username" value='<%=request.getParameter ("username")%>'>


<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
	<td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

<!-- Side Navigation start -->
<%@ include file="/jsp/admin/admin_menu.jsp" %>
<!-- end of the side navigations -->


<TD bgcolor="#ffffff">
<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
<TD valign="top" width="100%">

<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
<BR>

<%
    /*commented by sudhakar on 26th Nov 2004*/
	//ArrayList allUserIdsList = UserDAO.loadAllUserIDs (false /*also load expired and disabled accounts*/);
    /*Added by sudhakar on 26th Nov 2004*/
    /*to load only valid accounts*/
    ArrayList allUserIdsList = UserDAO.loadAllUserIDs (false /* load only valid accounts*/);
	request.setAttribute ("allUserIdsList", allUserIdsList);

	// see if userId, groupId, and email are coming from request
	String userIdFromRequest = request.getParameter ("userId");
	int groupIdFromRequest = -1;
	try {
		groupIdFromRequest = Integer.parseInt (request.getParameter ("groupId"));
	}
	catch (NumberFormatException nfe) {
		//System.out.println ("--> " + nfe);
	}

	int regionIdFromRequest = -1;
	try {
		regionIdFromRequest = Integer.parseInt (request.getParameter ("regionId"));
	}
	catch (NumberFormatException nfe) {
		//System.out.println ("--> " + nfe);
	}


	String firstNameFromRequest = request.getParameter ("firstName");
	String lastNameFromRequest = request.getParameter ("lastName");
	String phoneNumberFromRequest = request.getParameter ("phoneNumber");
	String faxNumberFromRequest = request.getParameter ("faxNumber");
	String emailFromRequest = request.getParameter ("email");
	String expiresOnFromRequest = request.getParameter ("expiresOn");

	// Check if we have to load level
	int levelIdFromRequest = -1;
	try {
		levelIdFromRequest = Integer.parseInt (request.getParameter ("levelId"));
	}
	catch (Exception ignore) {
		// no level parameter.
	}

	// Check if its a request to modify user settings
	boolean isUpdate = false;
	User userObject = null;

	String userAction  = request.getParameter ("useraction");

	if (("modify".equalsIgnoreCase (userAction ) == true) || ("view".equalsIgnoreCase (userAction ) == true)) {
		isUpdate = true;
	}

	String userName1 = request.getParameter ("username");


	if ( (userName1 != null) && (userName1.trim().length() != 0) && (!userName1.equals("-1")) && (!(userName1.equals("null"))) ) {
		//System.out.println("I am here without Userid  "+ userName1);
		try {
			userObject = UserDAO.loadUser (userName1, null /*password*/, true /*load even if its expired or disabled*/);

	    }
		catch (ScalarException se) {
			// Database exceptions
			// log it
			se.printStackTrace (System.err);
		}
	}



	if (userObject == null) {
		userObject = new User();
		java.util.Calendar cal = java.util.Calendar.getInstance();
		cal.add(java.util.Calendar.MONTH,6);
		java.util.Date dt = cal.getTime();
		//System.out.println("date   "+StringUtils.formatDateToString(dt,"MM/dd/yyyy"));
		userObject.setExpiresOn(StringUtils.formatDateToString(dt,"MM/dd/yyyy"));
	}

	if ((userIdFromRequest != null) && (userIdFromRequest.trim().length() != 0))
	{

		userObject.setUserId (userIdFromRequest);

	}
	else
	{
		if (userObject.getUserId() == null)
		{
			userObject.setUserId("");
		}
	}

	if ((firstNameFromRequest != null) && (firstNameFromRequest.trim().length() != 0))
	{
		userObject.setFirstName (firstNameFromRequest);
	}
	else
	{
		if (userObject.getFirstName() == null)
		{
			userObject.setFirstName ("");
		}
	}

	if ((lastNameFromRequest != null) && (lastNameFromRequest.trim().length() != 0))
	{
		userObject.setLastName (lastNameFromRequest);
	}
	else
	{
		if (userObject.getLastName() == null)
		{
			userObject.setLastName ("");
		}
	}

	if ((phoneNumberFromRequest != null) && (phoneNumberFromRequest.trim().length() != 0))
	{
		userObject.setPhoneNumber (phoneNumberFromRequest);
	}
	else
	{
		if (userObject.getPhoneNumber() == null)
		{
			userObject.setPhoneNumber ("");
		}
	}

	if ((faxNumberFromRequest != null) && (faxNumberFromRequest.trim().length() != 0))
	{
		userObject.setFaxNumber (faxNumberFromRequest);
	}
	else
	{
		if ( userObject.getFaxNumber() == null )
		{
			userObject.setFaxNumber("");
		}
	}

	if ( ( emailFromRequest != null ) && ( emailFromRequest.trim().length() != 0 ) )
	{
		userObject.setEmail (emailFromRequest);
	}
	else
	{
		if (userObject.getEmail() == null)
		{
			userObject.setEmail("");
		}
	}

	if (groupIdFromRequest != -1)
	{
		userObject.setUserGroupId (groupIdFromRequest);
	}
	if (regionIdFromRequest != -1)
	{
		userObject.setRegionId (regionIdFromRequest);
	}
    if (levelIdFromRequest  != -1)
	{
		userObject.setLevelId (levelIdFromRequest);
  	}

	if ((expiresOnFromRequest != null) && (expiresOnFromRequest.trim().length() != 0))
	{
		userObject.setExpiresOn (expiresOnFromRequest);
	}
	else
	{
		if (userObject.getExpiresOn() == null)
		{
			userObject.setExpiresOn("");
		}
	}


	// Load levels and groups from database
	ArrayList levelList = UserDAO.loadAllLevels();

	HashMap viewAccessMap = new HashMap();
	HashMap deleteAccessMap = new HashMap();
	HashMap modifyAccessMap = new HashMap();

	String flag = request.getParameter("selectflag");

 	if(flag!=null && flag.equals("0"))
	{
		ArrayList functionAccessList = new ArrayList();
		if( ("saveUserAs".equals(useraction)) || ("null".equals(useraction)) )
        {
			//System.out.println("First");
				functionAccessList = UserDAO.loadFunctionAccessListByUserId((String)request.getParameter("createNewUserAsUser"));
			if (functionAccessList == null || functionAccessList.size() == 0)
			{
				functionAccessList = new ArrayList();
			}
		}
		else
		{
			//System.out.println("Second");
		    functionAccessList = UserDAO.loadFunctionAccessListByUserId (userObject.getUserId());
			if (functionAccessList == null || functionAccessList.size() == 0)
			{
				functionAccessList = new ArrayList();
			}

		}
		int functionAccessListSize = functionAccessList.size();
		FunctionAccess functionAccess = null;

		for (int i=0; i<functionAccessListSize; i++)
		{
			functionAccess = (FunctionAccess) functionAccessList.get (i);
			viewAccessMap.put (functionAccess.getFunctionId()+"", ""+functionAccess.getView());
			deleteAccessMap.put (functionAccess.getFunctionId()+"", ""+functionAccess.getDelete());
			modifyAccessMap.put (functionAccess.getFunctionId()+"", ""+functionAccess.getModify());
		}

	}
	else if(flag!=null && flag.equals("1"))
	{
				//System.out.println("taking level values");
		ArrayList levelAccessList = UserDAO.loadLevelAccessListByLevelId (levelIdFromRequest);

		//System.out.println("finding by level id  "+ levelIdFromRequest);

		if (levelAccessList != null)
		{
	        int size = levelAccessList.size();
		    LevelAccess levelAccess = null;

			for (int i=0; i<size; i++)
			{
				levelAccess = (LevelAccess) levelAccessList.get (i);
				viewAccessMap.put (levelAccess.getFunctionId()+"", ""+levelAccess.getView());
				deleteAccessMap.put (levelAccess.getFunctionId()+"", ""+levelAccess.getDelete());
				modifyAccessMap.put (levelAccess.getFunctionId()+"", ""+levelAccess.getModify());
			}
		}
	}
	else if( request.getParameter ("username")!=null && !request.getParameter ("username").equals("-1") )
	{
				//System.out.println("taking user values 1  "+ userObject.getUserId());
	 	ArrayList functionAccessList = UserDAO.loadFunctionAccessListByUserId (userObject.getUserId());
		if (functionAccessList == null)
		{
			functionAccessList = new ArrayList();
		}

		int functionAccessListSize = functionAccessList.size();
		FunctionAccess functionAccess = null;

		for (int i=0; i<functionAccessListSize; i++)
		{
			functionAccess = (FunctionAccess) functionAccessList.get (i);
			viewAccessMap.put (functionAccess.getFunctionId()+"", ""+functionAccess.getView());
			deleteAccessMap.put (functionAccess.getFunctionId()+"", ""+functionAccess.getDelete());
			modifyAccessMap.put (functionAccess.getFunctionId()+"", ""+functionAccess.getModify());
		}

	}
	else if (levelIdFromRequest != -1)
	{
				//System.out.println("taking level values 1");
		ArrayList levelAccessList = UserDAO.loadLevelAccessListByLevelId (levelIdFromRequest);

		//System.out.println("finding by level id  "+ levelIdFromRequest);

		if (levelAccessList != null)
		{
	        int size = levelAccessList.size();
		    LevelAccess levelAccess = null;

			for (int i=0; i<size; i++)
			{
				levelAccess = (LevelAccess) levelAccessList.get (i);
				viewAccessMap.put (levelAccess.getFunctionId()+"", ""+levelAccess.getView());
				deleteAccessMap.put (levelAccess.getFunctionId()+"", ""+levelAccess.getDelete());
				modifyAccessMap.put (levelAccess.getFunctionId()+"", ""+levelAccess.getModify());
			}
		}
	}

	ArrayList regionList = UserDAO.loadAllRegions();

	if (regionList == null)
	{
		regionList = new ArrayList();
	}

	ArrayList userGroupList = UserDAO.loadAllUserGroups();
	if (userGroupList == null)
	{
		userGroupList = new ArrayList();
	}

	String[] userGroupNames = null;
	ArrayList[] functionsList = null;

	int groupSize = userGroupList.size();
	userGroupNames = new String[groupSize];
	functionsList = new ArrayList[groupSize];
	UserGroup userGroup = null;

	for (int i=0; i<groupSize; i++)
	{
		userGroup = (UserGroup) userGroupList.get(i);
		userGroupNames[i] = userGroup.getName();
		functionsList[i] = UserDAO.loadFunctionsByGroupID (userGroup.getId());
	}
%>


<!-- BODY STARTS HERE -->

<center><span class="NArialW">Users</span></center>
<img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" alt="" height="20">

  <table border="0" width="90%" align=right>
  <tr><td><a  name="#e1"></a></td></tr>
  <tr><td colspan='5'><chiptrack:info styleClass="NArialL" /></td></tr>
  <tr><td colspan='5'><chiptrack:errors styleClass="NArialL" /></td></tr>
  <tr><td colspan='5' class='NArialL'><font styleClass="NArialL" id='errors' color="FF0000" /></td></tr>
  <tr><td colspan ='5' align="left" class='NArialL'><font styleClass="NArialL" id="ErrorMessage" color="red"  />&nbsp;</td></tr>

    <tr><td><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" alt="" height=20></td></tr>
	<input type="hidden" name="selectflag" >
	<input type="hidden" name="flagValue" >

    <%if (("modify".equalsIgnoreCase (userAction ) == false) && ("view".equalsIgnoreCase (userAction ) == false)) {%>
    <tr><td colspan='5' class="NArialL">
        <font color='#993333'>Create the new User same as:&nbsp;&nbsp;</font>
        <select name='createNewUserAsUser' class='txfield' onchange="loadUserData()">
			<option value='-1'>-- Select one --</option>
			<%
				String temp = null;
                if(!"".equals(flag))
                {
                    temp = request.getParameter("username");
                }
				if(temp!=null){}
				else{ temp="@@@@@@@"; }
				for( int x=0 ; x < allUserIdsList.size() ; x++ )
				{
					org.apache.struts.util.LabelValueBean userDetail = (org.apache.struts.util.LabelValueBean)allUserIdsList.get(x);
					if(temp.equals(userDetail.getValue()))
					{
					%>
						<option value="<%=userDetail.getValue()%>" selected ><%=userDetail.getLabel()%></option>
					<%
					} else {
					%>
						<option value="<%=userDetail.getValue()%>"><%=userDetail.getLabel()%></option>
					<%}
				}
			%>
        </select>
    </td></tr>
    <tr><td colspan='5' class="NArialL"><font color='#993333'>Or create new: </font></td></tr>
    <tr><td><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tr>
    <%}%>


    <tr>
    	<td width="10%" class="NArialL">User Id:<font color="RED" size="1"><B> *</B></font></td>
    	<td width="20%" class="NArialL">
            <%if ((("modify".equalsIgnoreCase (userAction ) == true)) || ("view".equalsIgnoreCase (userAction ) == true)) {%>
                <%=userObject.getUserId()%>
                <input type="hidden" name="userId" value='<%=userObject.getUserId()%>'>
            <%}
			else if( ("saveUserAs".equalsIgnoreCase (userAction ) == true) ){
				if( ("True".equals(valuee)) || ("1".equals(flag1)) || ("0".equals(flag1)) ){
				%>
                <input type='text' name='userId' value='<%=(String)request.getParameter("userId")%>' size="25" maxlength='25' class='txfield'/>
				<% } else {
				%>
				 <input type='text' name='userId' value='<%//=(String)request.getParameter("userId")%>' size="25" maxlength='25' class='txfield'/>
				 <% }
			   }
			     else if( ("null".equalsIgnoreCase (userAction ) == true) ) {
				if( ("True".equals(valuee)) || ("1".equals(flag1)) || ("0".equals(flag1)) ){
				%>
                <input type='text' name='userId' value='<%=(String)request.getParameter("userId")%>' size="25" maxlength='25' class='txfield'/>
				<% } else {
				%>
				 <input type='text' name='userId' value='<%//=(String)request.getParameter("userId")%>' size="25" maxlength='25' class='txfield'/>
				 <% }
				}

             else {%>
                <input type='text' name='userId' value='<%=userObject.getUserId()%>' size="25" maxlength='25' class='txfield'/>
            <%}%>
                <input type="hidden" name="isUpdate" value="<%=isUpdate%>" size="25" maxlength='25' class="txfield">
        </td>
        <td width="15%" class="NArialL">Region:<font color="RED" size="1"><B> *</B></font></td>
		<td width="20%">
		<!-- Addded if condition by Sarada on 30th Sep to hide details of user from  new user -->
		<%if( ("saveUserAs".equalsIgnoreCase (userAction ) == true)) {
          if( ("True".equals(valuee)) || ("1".equals(flag1)) || ("1".equals(flagValue))){
    	%>
		<select name="regionId" onchange="addNewRegion()" class="txfield" <%if ("view".equalsIgnoreCase(userAction)) out.print ("disabled");%>>
            <%
                {
					int regionListSize = regionList.size();
					Region region = null;

					out.println ("<option value=\"-1\">--Select Region--");
                    out.println ("<option value=\"-2\">--Add New Region--");
                    for (int i=0; i<regionListSize; i++) {
					region = (Region) regionList.get(i);

					out.print ("<option value=\"" + region.getRegionId() + "\"");

					if (userObject.getRegionId() == region.getRegionId()) {
						out.print (" selected ");
					}
					else if(("saveUserAs".equalsIgnoreCase (userAction ) == true) )
					{
						if ( java.lang.Integer.parseInt(request.getParameter("regionId")) == region.getRegionId()) {
							out.print (" selected ");
						}
					}
					out.println ("> " + region.getRegionName());
					}
                }
            %>
            </select><%}
			else { %>
			<select name="regionId" onchange="addNewRegion()" class="txfield" <%if ("view".equalsIgnoreCase(userAction)) out.print ("disabled");%>>
            <%
                {
					int regionListSize = regionList.size();
					Region region = null;

					out.println ("<option value=\"-1\">--Select Region--");
                    out.println ("<option value=\"-2\">--Add New Region--");
                    for (int i=0; i<regionListSize; i++) {
						region = (Region) regionList.get(i);
						out.print ("<option value=\"" + region.getRegionId() + "\"");
						out.println ("> " + region.getRegionName());
					}
                }
            %>
            </select>

			<% } %>

		</td>
        <%}
		else if ("null".equalsIgnoreCase (userAction ) == true) {

          if( ("True".equals(valuee)) || ("1".equals(flag1))  ){

    	%>

		<select name="regionId" onchange="addNewRegion()" class="txfield" <%if ("view".equalsIgnoreCase(userAction)) out.print ("disabled");%>>
            <%
                {
					int regionListSize = regionList.size();
					Region region = null;

					out.println ("<option value=\"-1\">--Select Region--");
                    out.println ("<option value=\"-2\">--Add New Region--");
                    for (int i=0; i<regionListSize; i++) {
					region = (Region) regionList.get(i);
					out.print ("<option value=\"" + region.getRegionId() + "\"");

					if (userObject.getRegionId() == region.getRegionId()) {
						out.print (" selected ");
					}
					else if("saveUserAs".equalsIgnoreCase (userAction ) == true)
					{
						if ( java.lang.Integer.parseInt(request.getParameter("regionId")) == region.getRegionId()) {
							out.print (" selected ");
						}
					}
					out.println ("> " + region.getRegionName());
					}
                }
            %>
            </select><%}
			else { %>
			<select name="regionId" onchange="addNewRegion()" class="txfield" <%if ("view".equalsIgnoreCase(userAction)) out.print ("disabled");%>>
            <%
                {
					int regionListSize = regionList.size();
					Region region = null;

					out.println ("<option value=\"-1\">--Select Region--");
                    out.println ("<option value=\"-2\">--Add New Region--");
                    for (int i=0; i<regionListSize; i++) {
						region = (Region) regionList.get(i);
						out.print ("<option value=\"" + region.getRegionId() + "\"");
						out.println ("> " + region.getRegionName());
					}
                }
            %>
            </select>

			<% } %>

		</td>
        <%}
		else {%>
            
            <select name="regionId" onchange="addNewRegion()" class="txfield" <%if ("view".equalsIgnoreCase(userAction)) out.print ("disabled");%>>
            <%
                {
					int regionListSize = regionList.size();
					Region region = null;

					out.println ("<option value=\"-1\">--Select Region--");
                    out.println ("<option value=\"-2\">--Add New Region--");
                    for (int i=0; i<regionListSize; i++) {
					region = (Region) regionList.get(i);
					out.print ("<option value=\"" + region.getRegionId() + "\"");

					if (userObject.getRegionId() == region.getRegionId()) {
						out.print (" selected ");
					}
					else if("saveUserAs".equalsIgnoreCase (userAction ) == true)
					{
						if ( java.lang.Integer.parseInt(request.getParameter("regionId")) == region.getRegionId()) {
							out.print (" selected ");
						}
					}
					out.println ("> " + region.getRegionName());
					}
                }
            %>
            </select>
        </td>
		<% } %>
    	<td width="10%">&nbsp;</td>
    </tr>
     <TR>
         <td width="10%">&nbsp;</td>
		 <td width="20%">&nbsp;</td>
         <td width="15%" class="NArialL" id="newRegion">New Region:<font color="RED" size="1"><B> *</B></font></td>
		 <td width="20%"><html:text property="newRegion" name="userSetupForm" size="25" maxlength='50' styleClass='txfield'/> </td>
         <td width="10%">&nbsp;</td>
     </TR>
    <%if ("view".equalsIgnoreCase(userAction) == false) {%>
    <tr>
    	<td width="10%" class="NArialL">Password:<font color="RED" size="1"><B> *</B></font></td>
    	<td width="20%">
		<%if ("saveUserAs".equalsIgnoreCase (userAction ) == true) {
				if( ("True".equals(valuee)) || ("1".equals(flag1)) || ("0".equals(flag1))){
				%>
                <input type='password' name='password' value='<%=(String)request.getParameter("password")%>' size="25" maxlength='8' class='txfield'/>
				<% } else {%>
				 <input type='password' name='password' value='<%//=(String)request.getParameter("password")%>' size="25" maxlength='8' class='txfield'/>
				 <% } %>

		<%}
		else if ("null".equalsIgnoreCase (userAction ) == true) {
				if( ("True".equals(valuee)) || ("1".equals(flag1)) || ("0".equals(flag1))){
				%>
                <input type='password' name='password' value='<%=(String)request.getParameter("password")%>' size="25" maxlength='8' class='txfield'/>
				<% } else {%>
				 <input type='password' name='password' value='<%//=(String)request.getParameter("password")%>' size="25" maxlength='8' class='txfield'/>
				 <% } %>

		<%}

		else {%>
			<input type="password" name="password" size="25" maxlength='8' class="txfield" class='txfield'>
		<% } %>
		</td>
    	<td width="15%" class="NArialL">Confirm Password:<font color="RED" size="1"><B> *</B></font></td>
    	<td width="20%">

		<%if ("saveUserAs".equalsIgnoreCase (userAction ) == true) {

			if( ("True".equals(valuee)) || ("1".equals(flag1)) || ("0".equals(flag1)) ){
				%>
                <input type='password' name='password1' value='<%=(String)request.getParameter("password1")%>' size="25" maxlength='8' class='txfield'/>
				<% } else {%>
				<input type='password' name='password1' value='<%//=(String)request.getParameter("password1")%>' size="25" maxlength='8' class='txfield'/>
				 <% } %>
		<%}
			else if ("null".equalsIgnoreCase (userAction ) == true) {

				if( ("True".equals(valuee)) || ("1".equals(flag1)) || ("0".equals(flag1))){
				%>
                <input type='password' name='password1' value='<%=(String)request.getParameter("password1")%>' size="25" maxlength='8' class='txfield'/>
				<% } else {%>
				<input type='password' name='password1' value='<%//=(String)request.getParameter("password1")%>' size="25" maxlength='8' class='txfield'/>
				 <% } %>

		<%}
			else {%>
			<input type="password" name="password1" size="25" maxlength='8' class="txfield" class='txfield'>
		<% } %>

		</td>
    	<td width="10%">&nbsp</td>
    </tr>
    <%}%>

    <%
        boolean modifyOrView = false;
        if (("modify".equalsIgnoreCase (userAction ) == true) || ("view".equalsIgnoreCase (userAction ) == true)) {
            modifyOrView = true;
        }
    %>
    <tr>
    	<td width="10%" class="NArialL">First Name:<font color="RED" size="1"><B> *</B></font></td>
   		<!-- Addded if condition by Sarada on 30th Sep to hide details of user from  new user -->
		<td width="20%">
		<%if ("saveUserAs".equalsIgnoreCase (userAction ) == true) {
			if( ("True".equals(valuee)) || ("1".equals(flag1)) || ("0".equals(flag1)) ){

				%>
                <input type='text' name='firstName' value='<%=(String)request.getParameter("firstName")%>' size="25" maxlength='25' class='txfield'/>
				<% } else {%>
				 <input type='text' name='firstName' value='<%//=(String)request.getParameter("firstName")%>' size="25" maxlength='25' class='txfield'/>
				 <% } %>
        <%}
      else if ("null".equalsIgnoreCase (userAction ) == true) {
			if( ("True".equals(valuee)) || ("1".equals(flag1)) || ("0".equals(flag1)) ){

				%>
                <input type='text' name='firstName' value='<%=(String)request.getParameter("firstName")%>' size="25" maxlength='25' class='txfield'/>
				<% } else {%>
				 <input type='text' name='firstName' value='<%//=(String)request.getParameter("firstName")%>' size="25" maxlength='25' class='txfield'/>
				 <% } %>
        <%}

		else { %>
        <input type="text" name="firstName" value='<%=userObject.getFirstName()%>' size="25" maxlength='25' class='txfield' <%if ("view".equalsIgnoreCase(userAction)) out.print ("disabled");%>></td>
        <%}%>


    	<td width="15%" class="NArialL">Last Name:</td>
   		<!-- Addded if condition by Sarada on 30th Sep to hide details of user from  new user -->
		<td width="20%">
        <%
		if( ("saveUserAs".equalsIgnoreCase (userAction ) == true) ){
			if( ("True".equals(valuee)) || ("1".equals(flag1)) || ("0".equals(flag1)) ){

				%>
                <input type='text' name='lastName' value='<%=(String)request.getParameter("lastName")%>' size="25" maxlength='25' class='txfield'/>
				<% } else { %>
				 <input type='text' name='lastName' value='<%//=(String)request.getParameter("lastName")%>' size="25" maxlength='25' class='txfield'/>
				 <% } %>
        <%}
			else if( ("null".equalsIgnoreCase (userAction ) == true) ){
			if( ("True".equals(valuee)) || ("1".equals(flag1)) || ("0".equals(flag1)) ){

				%>
                <input type='text' name='lastName' value='<%=(String)request.getParameter("lastName")%>' size="25" maxlength='25' class='txfield'/>
				<% } else { %>
				 <input type='text' name='lastName' value='<%//=(String)request.getParameter("lastName")%>' size="25" maxlength='25' class='txfield'/>
				 <% } %>
        <%}
				else { %>
    	<input type="text" name="lastName" value='<%=userObject.getLastName()%>' size="25" maxlength='25' class='txfield' <%if ("view".equalsIgnoreCase(userAction)) out.print ("disabled");%>></td>
        <%}%>
    	<td width="10%">&nbsp</td>
    </tr>

    <tr>
    	<td width="10%"><font class="NArialL">Phone Number:</font></td>
   		<!-- Addded if condition by Sarada on 30th Sep to hide details of user from  new user -->
		<td width="20%">
		<%if ("saveUserAs".equalsIgnoreCase (userAction ) == true) {

			if( ("True".equals(valuee)) || ("1".equals(flag1)) || ("0".equals(flag1)) ){
				%>
                <input type='text' name='phoneNumber' value='<%=(String)request.getParameter("phoneNumber")%>' size="25" maxlength='25' class='txfield' onkeypress='validatePhoneNumber(this)'/>
				<% } else {%>
				 <input type='text' name='phoneNumber' value='<%//=(String)request.getParameter("phoneNumber")%>' size="25" maxlength='25' class='txfield' onkeypress='validatePhoneNumber(this)'/>
				 <% } %>
        <%}
		else if ("null".equalsIgnoreCase (userAction ) == true) {

			if( ("True".equals(valuee)) || ("1".equals(flag1)) || ("0".equals(flag1)) ){
				%>
                <input type='text' name='phoneNumber' value='<%=(String)request.getParameter("phoneNumber")%>' size="25" maxlength='25' class='txfield' onkeypress='validatePhoneNumber(this)'/>
				<% } else {%>
				 <input type='text' name='phoneNumber' value='<%//=(String)request.getParameter("phoneNumber")%>' size="25" maxlength='25' class='txfield' onkeypress='validatePhoneNumber(this)'/>
				 <% } %>
        <%}


		else { %>
    	<input type="text" name="phoneNumber" value='<%=userObject.getPhoneNumber()%>' size="25" maxlength='50' class='txfield' <%if ("view".equalsIgnoreCase(userAction)) out.print ("disabled");%> onkeypress='validatePhoneNumber(this)'></td>
		 <%}%>
    	<td width="15%"><font class="NArialL">Fax Number:</font></td>
   		<!-- Addded if condition by Sarada on 30th Sep to hide details of user from  new user -->
		<td width="20%">
		<%if ("saveUserAs".equalsIgnoreCase (userAction ) == true) {
			if( ("True".equals(valuee)) || ("1".equals(flag1)) || ("0".equals(flag1)) ){
				%>
                <input type='text' name='faxNumber' value='<%=(String)request.getParameter("faxNumber")%>' size="25" maxlength='25' class='txfield' onkeypress='validatePhoneNumber(this)'/>
				<% } else {%>
				 <input type='text' name='faxNumber' value='<%//=(String)request.getParameter("faxNumber")%>' size="25" maxlength='25' class='txfield' onkeypress='validatePhoneNumber(this)'/>
				 <% } %>
        <%}
			else if ("null".equalsIgnoreCase (userAction ) == true) {
			if( ("True".equals(valuee)) || ("1".equals(flag1)) || ("0".equals(flag1)) ){
				%>
                <input type='text' name='faxNumber' value='<%=(String)request.getParameter("faxNumber")%>' size="25" maxlength='25' class='txfield' onkeypress='validatePhoneNumber(this)'/>
				<% } else {%>
				 <input type='text' name='faxNumber' value='<%//=(String)request.getParameter("faxNumber")%>' size="25" maxlength='25' class='txfield' onkeypress='validatePhoneNumber(this)'/>
				 <% } %>
        <%}
				else {%>
    	<input type="text" name="faxNumber" value='<%=userObject.getFaxNumber()%>' size="25" maxlength='50' class='txfield' <%if ("view".equalsIgnoreCase(userAction)) out.print ("disabled");%> onkeypress='validatePhoneNumber(this)'></td>
		 <%}%>
    	<td width="10%">&nbsp</td>
    </tr>

    <tr>
    	<td width="10%"><font class="NArialL">User Group:</font><font color="RED" size="1"><B> *</B></font></td>
    	<td width="20%">

            <select name="userGroupId" class="txfield" <%if ("view".equalsIgnoreCase(userAction)) out.print ("disabled");%> >
            <%
                {
						int groupListSize = userGroupList.size();
						UserGroup group = null;

						out.println ("<option value=\"-1\">--Select Group--");
						for (int i=0; i<groupListSize; i++)
						{
						group = (UserGroup) userGroupList.get(i);
						out.print ("<option value=\"" + group.getId() + "\"");
                        if(!"".equals(flag))
                        {
                            if (userObject.getUserGroupId() == group.getId())
                                {
                                out.print (" selected ");
                                }
                        }

						out.println ("> " + group.getName());
                    }
                }
            %>
            </select>

        </td>

       	<td width="15%"><font class="NArialL">Email:</font><font color="RED" size="1"><B> *</B></font></td>
   		<!-- Addded if condition by Sarada on 30th Sep to hide details of user from  new user -->
		<td width="20%">
		<%if ("saveUserAs".equalsIgnoreCase (userAction ) == true) {
			if( ("True".equals(valuee)) || ("1".equals(flag1)) || ("0".equals(flag1)) ){
				%>
                <input type='text' name='email' value='<%=(String)request.getParameter("email")%>' size="25"  maxlength="100" class='txfield'/>
				<% } else {%>
				 <input type='text' name='email' value='<%//=(String)request.getParameter("email")%>' size="25" maxlength="100"  class='txfield'/>
				 <% } %>
        <%}
			else if ("null".equalsIgnoreCase (userAction ) == true) {
			if( ("True".equals(valuee)) || ("1".equals(flag1)) || ("0".equals(flag1)) ){
				%>
                <input type='text' name='email' value='<%=(String)request.getParameter("email")%>' size="25" maxlength="100" class='txfield'/>
				<% } else {%>
				 <input type='text' name='email' value='<%//=(String)request.getParameter("email")%>' size="25" maxlength="100" class='txfield'/>
				 <% } %>
        <%}

				else {%>

            <input type="text" name="email" value="<%=userObject.getEmail()%>" size="25" maxlength="100" <%if ("view".equalsIgnoreCase(userAction)) out.print ("disabled");%> class='txfield'>
        </td>
		 <%}%>
    	<td width="10%">&nbsp</td>
    </tr>

    <tr>
        <td width="10%"><font class="NArialL">Expires On:</font></td>
    	<td width="20%"><input type="text" name="expiresOn" value='<%=userObject.getExpiresOn()%>' size="11" maxlength='10' <%if ("view".equalsIgnoreCase(userAction)) out.print ("disabled");%> class='txfield' >&nbsp;
        <%if ("view".equalsIgnoreCase(userAction) == false) {%>
        <a href="javascript:openCalendar(document.userSetupForm.expiresOn)">
        <%}%>
        <img onMouseOver="window.status='Click here to select date';return true" border="0" align='center' src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=20 width=20></a>
        </td>

    	<td width="45%" colspan='3'><font class="NArialL">
   		<!-- Addded if condition by Sarada on 30th Sep to hide details of user from  new user -->

		<%
		if ("saveUserAs".equalsIgnoreCase (userAction ) == true)
		{
			if( ("True".equals(valuee)) || ("1".equals(flag1)) || ("0".equals(flag1)))
			{ %>
    	<input type="checkbox" name="receiveNotifications" value='on' class="txfield"
		<%  //String ff = request.getParameter("receiveNotifications");
			if ( "on".equalsIgnoreCase( userObject.getReceiveNotifications() ) || Boolean.valueOf ( request.getParameter("recNotif") ) == Boolean.TRUE )
			{	out.print ("checked");	}
			else
			{	out.print ("unchecked"); }
		%> />&nbsp;&nbsp;Receive Notifications
		<% }
		   else
		   { %>
			<input type="checkbox" name="receiveNotifications" value='on' class="txfield"
			<% String ff1 = request.getParameter("receiveNotifications");
				if ("on".equalsIgnoreCase(userObject.getReceiveNotifications()))
			   {
				out.print ("checked");
			   }

			%> />&nbsp;&nbsp;Receive Notifications <%
			} %>

        <%}
		else if ( ( userAction == null ) == true )
		{
			if( ("True".equals(valuee)) || ("1".equals(flag1)) || ("0".equals(flag1)))
			{ %>
    	<input type="checkbox" name="receiveNotifications" value='on' class="txfield"
		<%   String ff = request.getParameter("receiveNotifications");
			if (ff != null )
			{	out.print ("checked");	}
			else
			{	out.print ("unchecked"); }
		%> />&nbsp;&nbsp;Receive Notifications
		<% }
		   else
		   { %>
			<input type="checkbox" name="receiveNotifications" value='on' class="txfield"
			<%String ff1 = request.getParameter("receiveNotifications");

				if ("on".equalsIgnoreCase(userObject.getReceiveNotifications()))
			   {
				out.print ("checked");
			   }

			%> />&nbsp;&nbsp;Receive Notifications <%
			} %>

        <%}
		else {%>
		<input type='checkbox' <%if ("view".equalsIgnoreCase(userAction)) out.print ("disabled");%> name='receiveNotifications' value='on' class="txfield"
		<% String ff2 = request.getParameter("receiveNotifications");
		if ("on".equalsIgnoreCase(userObject.getReceiveNotifications()) || Boolean.valueOf ( request.getParameter("recNotif") ) == Boolean.TRUE )
			{
		out.print ("checked");}
		%>
		/>&nbsp;&nbsp;Receive Notifications
		<%}%>
		</font></td>
    </tr>
		<%if ( ( "saveUserAs".equalsIgnoreCase ( userAction ) == true ) || (  userAction  == null )  || "null".equalsIgnoreCase( userAction ) )
		{ %>

                <tr>
                <% if( userObject.getSalesAckMail() == true || Boolean.valueOf ( request.getParameter("salAckMail") ) == Boolean.TRUE ){%>
                <td width="25%" align='left' colspan=2><input type="checkbox" name="salesAckMail"  value='on'  checked class="txfield" > <FONT class='NArialL'>Receive SalesOrder Acknowledge Mails </FONT> </td>
                <%} else{%>
                <td width="25%" align='left' colspan=2><input type="checkbox" name="salesAckMail"  value='on' unchecked  class="txfield" > <FONT class='NArialL'>Receive SalesOrder Acknowledge Mails </FONT> </td>
                 <%}%>
                 <% if( userObject.getShipAlerts() == true || Boolean.valueOf ( request.getParameter("shipAlerts") ) == Boolean.TRUE ){%>
                <td width="25%" align='left' colspan=2><input type="checkbox" name="shipAlerts"  value='on'  checked  class="txfield"> <FONT class='NArialL'>Receive Ship Alert Mails </FONT> </td>
                <%} else{%>
                <td width="25%" align='left' colspan=2><input type="checkbox" name="shipAlerts"  value='on' unchecked class="txfield" > <FONT class='NArialL'>Receive Ship Alert Mails </FONT> </td>
                 <%}%>
                 </tr>
                <tr>
                <% if( userObject.getProformaInvoice() == true || Boolean.valueOf ( request.getParameter("proformaInv") ) == Boolean.TRUE ){%>
                    <td width="25%" align='left' colspan=2><input type="checkbox" name="proformaInvoice"  value='on'  checked class="txfield" > <FONT class='NArialL'>Receive Proforma Invoice Mails </FONT> </td>
                <%} else{%>
                    <td width="25%" align='left' colspan=2><input type="checkbox" name="proformaInvoice"  value='on' unchecked class="txfield" > <FONT class='NArialL'>Receive Proforma Invoice Mails </FONT> </td>
                <%}%>
                <% if( userObject.getPackingSlip() == true  || Boolean.valueOf ( request.getParameter("pacSlip") ) == Boolean.TRUE ){%>
                    <td width="25%" align='left' colspan=2><input type="checkbox" name="packingSlip"  value='on'  checked class="txfield" > <FONT class='NArialL'>Receive Packing Slip Mails </FONT> </td>
                <%} else{%>
                    <td width="25%" align='left' colspan=2><input type="checkbox" name="packingSlip"  value='on' unchecked class="txfield" > <FONT class='NArialL'>Receive Packing Slip Mails </FONT> </td>
                <%}%>
                </tr>
                <tr>
                <% if( userObject.isQuoteAckMail() == true || Boolean.valueOf ( request.getParameter("quoAckMail") ) == Boolean.TRUE ){%>
                <td width="25%" align='left' colspan=2><input type="checkbox" name="quoteAckMail"  value='on'  checked class="txfield" > <FONT class='NArialL'>Receive Quote Acknowledge Mails </FONT> </td>
                <%} else{%>
                <td width="25%" align='left' colspan=2><input type="checkbox" name="quoteAckMail"  value='on' unchecked  class="txfield" > <FONT class='NArialL'>Receive Quote Acknowledge Mails </FONT> </td>
                 <%}%>
                <% if( userObject.isRmaAckMail() == true || Boolean.valueOf ( request.getParameter("rmaAckMail") ) == Boolean.TRUE ){%>
                <td width="25%" align='left' colspan=2><input type="checkbox" name="rmaAckMail"  value='on'  checked class="txfield" ><FONT class='NArialL'> Receive RMA Acknowledge Mails </FONT></td>
                <%} else{%>
                <td width="25%" align='left' colspan=2><input type="checkbox" name="rmaAckMail"  value='on' unchecked class="txfield" ><FONT class='NArialL'>Receive RMA Acknowledge Mails </FONT></td>
                 <%}%>
                </tr>
        <%}%>

         <%if ("modify".equalsIgnoreCase (userAction ) == true)
		{%>    <tr>
                <% if( userObject.getSalesAckMail() == true || Boolean.valueOf ( request.getParameter("salAckMail") ) == Boolean.TRUE ){%>
                <td width="25%" align='left' colspan=2><input type="checkbox" name="salesAckMail"  value='on'  checked class="txfield" > <FONT class='NArialL'> Receive SalesOrder Acknowledge Mails </FONT> </td>
                <%} else{%>
                <td width="25%" align='left' colspan=2><input type="checkbox" name="salesAckMail"  value='on' unchecked class="txfield" > <FONT class='NArialL'>Receive SalesOrder Acknowledge Mails </FONT> </td>
                 <%}%>
                 <% if( userObject.getShipAlerts() == true || Boolean.valueOf ( request.getParameter("shipAlerts") ) == Boolean.TRUE  ){%>
                <td width="25%" align='left' colspan=2><input type="checkbox" name="shipAlerts"  value='on'  checked class="txfield" > <FONT class='NArialL'>Receive Ship Alert Mails </FONT> </td>
                <%} else{%>
                <td width="25%" align='left' colspan=2><input type="checkbox" name="shipAlerts"  value='on' unchecked  class="txfield" > <FONT class='NArialL'>Receive Ship Alert Mails </FONT> </td>
                 <%}%>

                 </tr>
                <tr>
                <% if( userObject.getProformaInvoice() == true || Boolean.valueOf ( request.getParameter("proformaInv") ) == Boolean.TRUE  ){%>
                    <td width="25%" align='left' colspan=2><input type="checkbox" name="proformaInvoice"  value='on'  checked  class="txfield" > <FONT class='NArialL'>Receive Proforma Invoice Mails </FONT> </td>
                <%} else{%>
                    <td width="25%" align='left' colspan=2><input type="checkbox" name="proformaInvoice"  value='on' unchecked  class="txfield" > <FONT class='NArialL'>Receive Proforma Invoice Mails </FONT> </td>
                <%}%>
                <% if( userObject.getPackingSlip() == true || Boolean.valueOf ( request.getParameter("pacSlip") ) == Boolean.TRUE  ){%>
                    <td width="25%" align='left' colspan=2><input type="checkbox" name="packingSlip"  value='on'  checked  class="txfield" > <FONT class='NArialL'>Receive Packing Slip Mails </FONT> </td>
                <%} else{%>
                    <td width="25%" align='left' colspan=2><input type="checkbox" name="packingSlip"  value='on' unchecked class="txfield" > <FONT class='NArialL'>Receive Packing Slip Mails </FONT> </td>
                <%}%>
                </tr>
                <tr>
                <% if( userObject.isQuoteAckMail() == true || Boolean.valueOf ( request.getParameter("quoAckMail") ) == Boolean.TRUE ){%>
                <td width="25%" align='left' colspan=2><input type="checkbox" name="quoteAckMail"  value='on'  checked class="txfield" > <FONT class='NArialL'>Receive Quote Acknowledge Mails </FONT> </td>
                <%} else{%>
                <td width="25%" align='left' colspan=2><input type="checkbox" name="quoteAckMail"  value='on' unchecked class="txfield" > <FONT class='NArialL'>Receive Quote Acknowledge Mails </FONT> </td>
                 <%}%>
                <% if( userObject.isRmaAckMail() == true || Boolean.valueOf ( request.getParameter("rmaAckMail") ) == Boolean.TRUE ){%>
                <td width="25%" align='left' colspan=2><input type="checkbox" name="rmaAckMail"  value='on'  checked class="txfield" ><FONT class='NArialL'> Receive RMA Acknowledge Mails </FONT></td>
                <%} else{%>
                <td width="25%" align='left' colspan=2><input type="checkbox" name="rmaAckMail"  value='on' unchecked class="txfield" ><FONT class='NArialL'> Receive RMA Acknowledge Mails </FONT></td>
                 <%}%>
                 </tr>
        <%}%>

         <%if ("view".equalsIgnoreCase (userAction ) == true)
		{ %>
                <tr>
                <% if( userObject.getSalesAckMail() == true ){%>
                <td width="25%" align='left' colspan=2><input type="checkbox" disabled  name="salesAckMail"  value='on'  checked class="txfield" > <FONT class='NArialL'>Receive SalesOrder Acknowledge Mails </FONT> </td>
                <%} else{%>
                <td width="25%" align='left' colspan=2><input type="checkbox" disabled  name="salesAckMail"  value='on' unchecked class="txfield" > <FONT class='NArialL'>Receive SalesOrder Acknowledge Mails </FONT> </td>
                 <%}%>
                 <% if( userObject.getShipAlerts() == true ){%>
                <td width="25%" align='left' colspan=2><input type="checkbox" disabled  name="shipAlerts"  value='on'  checked class="txfield" > <FONT class='NArialL'>Receive Ship Alert Mails </FONT> </td>
                <%} else{%>
                <td width="25%" align='left' colspan=2><input type="checkbox" disabled  name="shipAlerts"  value='on' unchecked class="txfield" > <FONT class='NArialL'>Receive Ship Alert Mails </FONT> </td>
                 <%}%>
                 </tr>
                 <tr>
                <% if( userObject.getProformaInvoice() == true ){%>
                    <td width="25%" align='left' colspan=2><input type="checkbox" disabled name="proformaInvoice"  value='on'  checked class="txfield" > <FONT class='NArialL'>Receive Proforma Invoice Mails </FONT> </td>
                <%} else{%>
                    <td width="25%" align='left' colspan=2><input type="checkbox" disabled  name="proformaInvoice"  value='on' unchecked class="txfield" > <FONT class='NArialL'>Receive Proforma Invoice Mails </FONT> </td>
                <%}%>
                <% if( userObject.getPackingSlip() == true ){%>
                    <td width="25%" align='left' colspan=2><input type="checkbox" disabled name="packingSlip"  value='on'  checked class="txfield" > <FONT class='NArialL'>Receive Packing Slip Mails </FONT> </td>
                <%} else{%>
                    <td width="25%" align='left' colspan=2><input type="checkbox" disabled name="packingSlip"  value='on' unchecked class="txfield" > <FONT class='NArialL'>Receive Packing Slip Mails </FONT> </td>
                <%}%>
                </tr>
                <tr>
                <% if( userObject.isQuoteAckMail() == true ){%>
                <td width="25%" align='left' colspan=2><input type="checkbox" disabled  name="quoteAckMail"  value='on'  checked class="txfield" > <FONT class='NArialL'>Receive Quote Acknowledge Mails </FONT> </td>
                <%} else{%>
                <td width="25%" align='left' colspan=2><input type="checkbox" disabled  name="quoteAckMail"  value='on' unchecked class="txfield" > <FONT class='NArialL'>Receive Quote Acknowledge Mails </FONT> </td>
                <%}%>
                <% if( userObject.isRmaAckMail() == true || Boolean.valueOf ( request.getParameter("rmaAckMail") ) == Boolean.TRUE ){%>
                <td width="25%" align='left' colspan=2><input type="checkbox" name="rmaAckMail"  value='on'  checked class="txfield" ><FONT class='NArialL'> Receive RMA Acknowledge Mails </FONT></td>
                <%} else{%>
                <td width="25%" align='left' colspan=2><input type="checkbox" name="rmaAckMail"  value='on' unchecked class="txfield" ><FONT class='NArialL'> Receive RMA Acknowledge Mails </FONT></td>
                 <%}%>
                </tr>
        <%}%>



    <tr><td colspan='5'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tr>

    <tr>
    </tr>

    <tr>
    <td colspan='5'><font class="NArialL">Select Pre-Defined Access Level to Load</font>&nbsp;&nbsp;
  <!--
    <select name="levelId" class="txfield" onchange="loadLevel('levelId')" <% //if ("view".equalsIgnoreCase(userAction)) out.print ("disabled");%> >
                <% /*
                {
					int levelListSize = levelList.size();
					//Level level = null;

					out.println ("<option value=\"-1\">--Select Level--");
					for (int i=0; i<levelListSize; i++) {
					level = (Level) levelList.get(i);
					out.print ("<option value=\"" + level.getId() + "\"");
					if (levelIdFromRequest == level.getId()) {
						out.print (" selected ");
					}
					//System.out.println("level.getName()"+level.getName());
					out.println ("> " + level.getName());
					}
                } */
                %>

            </select> -->

      <!-- Addded if condition by chandra sekahr on 8th Nov to hide details of user from  new user -->
		<%if( ("saveUserAs".equalsIgnoreCase (userAction ) == true)){
          if( ("True".equals(valuee)) || ("1".equals(flag1)) || ("1".equals(flagValue))){
    	%>
		<select name="levelId" class="txfield"  onchange="loadLevel('levelId')" <%if ("view".equalsIgnoreCase(userAction)) out.print ("disabled");%>>
            <%
               {
					int levelListSize = levelList.size();
					Level level1 = null;

					out.println ("<option value=\"-1\">--Select Level--");
					for (int i=0; i<levelListSize; i++) {
					level1 = (Level) levelList.get(i);
					out.print ("<option value=\"" + level1.getId() + "\"");

					if (userObject.getLevelId() == level1.getId())
                    {
						out.print (" selected ");
					}
                    else if(("saveUserAs".equalsIgnoreCase (userAction ) == true) )
					{
						if ( java.lang.Integer.parseInt(request.getParameter("levelId")) == level1.getId()) {
							out.print (" selected ");
						}
					}

					//System.out.println("level.getName()"+level1.getName());
					out.println ("> " + level1.getName());
					}
                }

            %>
            </select><%}
			else { %>
			<select name="levelId" class="txfield" onchange="loadLevel('levelId')" <%if ("view".equalsIgnoreCase(userAction)) out.print ("disabled");%>>
            <%
                {
                    int levelListSize = levelList.size();
                    Level level1 = null;

                    out.println ("<option value=\"-1\">--Select Level--");
                    for (int i=0; i<levelListSize; i++) {
                    level1 = (Level) levelList.get(i);
                    out.print ("<option value=\"" + level1.getId() + "\"");
					out.println ("> " +  level1.getName());
					}
                }
            %>
            </select>

			<% } %>

		</td>
        <%}
		else if ("null".equalsIgnoreCase (userAction ) == true) {

          if( ("True".equals(valuee)) || ("1".equals(flag1))  ){

    	%>
		<select name="levelId" class="txfield" onchange="loadLevel('levelId')" <%if ("view".equalsIgnoreCase(userAction)) out.print ("disabled");%>>
            <%
                {
					int levelListSize = levelList.size();
					Level level1 = null;

					out.println ("<option value=\"-1\">--Select Level--");
					for (int i=0; i<levelListSize; i++) {
					level1 = (Level) levelList.get(i);
					out.print ("<option value=\"" + level1.getId() + "\"");

					if (userObject.getLevelId() == level1.getId())
                    {
						out.print (" selected ");
					}
                    else if(("saveUserAs".equalsIgnoreCase (userAction ) == true) )
					{
						if ( java.lang.Integer.parseInt(request.getParameter("levelId")) == level1.getId()) {
							out.print (" selected ");
						}
					}

					//System.out.println("level.getName()"+level1.getName());
					out.println ("> " + level1.getName());
					}
                }
            %>
            </select><%}
			else { %>
			<select name="levelId" class="txfield" onchange="loadLevel('levelId')" <%if ("view".equalsIgnoreCase(userAction)) out.print ("disabled");%>>
            <%
                {
					 int levelListSize = levelList.size();
                    Level level1 = null;

                    out.println ("<option value=\"-1\">--Select Level--");
                    for (int i=0; i<levelListSize; i++) {
                    level1 = (Level) levelList.get(i);
                    out.print ("<option value=\"" + level1.getId() + "\"");
					out.println ("> " +  level1.getName());
					}
                }
            %>
            </select>

			<% } %>

		</td>
        <%}
		else {%>

            <select name="levelId" class="txfield"  onchange="loadLevel('levelId')" <%if ("view".equalsIgnoreCase(userAction)) out.print ("disabled");%>>
            <%
                {
					int levelListSize = levelList.size();
					Level level1 = null;

					out.println ("<option value=\"-1\">--Select Level--");
					for (int i=0; i<levelListSize; i++) {
					level1 = (Level) levelList.get(i);
					out.print ("<option value=\"" + level1.getId() + "\"");

					if (userObject.getLevelId() == level1.getId())
                    {
						out.print (" selected ");
					}
                    else if(("saveUserAs".equalsIgnoreCase (userAction ) == true) )
					{
						if ( java.lang.Integer.parseInt(request.getParameter("levelId")) == level1.getId()) {
							out.print (" selected ");
						}
					}

					//System.out.println("level.getName()"+level1.getName());
					out.println ("> " + level1.getName());
					}
                }
            %>
            </select>
        </td>
		<% } %>

       </tr>

    <tr><td colspan=5>


<!-- GROUPS AND FUNCTIONALITY DISPLAY CODE STARTS HERE -->
<table border="0" width="85%">

<%
if (userGroupList != null) {

    int userGroupSize = userGroupList.size();
    String headValue = null;
    String linkValue = null;
    String showHide = null;

    // Write the table row for each user group
    for (int index=0; index<userGroupSize; index++) {

        headValue = "head" + index;             //
        linkValue = "link" + index;             // Values used by the script
        showHide = "ShowHide(" + index + ")";   //

        // We have user group name and corresponding permissions
        // Generate equivalent HTML Code to display this user group
%>

<tr>
<td ID='<%=headValue%>' ALIGN='left' width="113" height="15" CLASS="HEADING" ONCLICK='<%=showHide%>'><%=userGroupNames[index]%></td>
</tr>
<tr>
<td ALIGN="left">
<div ID='<%=linkValue%>' CLASS="LINKSOFF">

        <table border="1" width="100%" bordercolor="#FFFFFF">
            <tr>
                <td width="33%" align="center" bgcolor="#993333" class="NArialL">
                    <p align="center"><font color="#FFFFFF"> Functionality </font></p>
                </td>
                <td width="66%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF"> Actions </font></td>
	  </tr>
<%
        // Print out HTML Equivalent to display each functionality name
        // and its corresponding actions
        Functionality functionality = null;
        int functionNamesSize = functionsList[index].size();
        String functionName = null;
        int functionId = -1;
        int groupId = -1;
        for (int j=0; j<functionNamesSize; j++) {
            functionality = (Functionality) functionsList[index].get(j);
            functionName = functionality.getName();
			//System.out.println("functionName"+functionName );
            functionId = functionality.getId();
            groupId = functionality.getGroupId();
%>


                <tr>
                <td width="33%" align="center" <%if (j%2 == 0) out.print ("bgcolor='#DEE1E2'");%>><font class="NArialL"><%=functionName%></font></td>
                <td width="66%" align="left" <%if (j%2 == 0) out.print ("bgcolor='#DEE1E2'");%>><font class="NArialL">

                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <%
					if( (functionality.getView() == true)) {%>
                    <input type='checkbox' class="txfield"  <%if ("true".equalsIgnoreCase ((String) viewAccessMap.get (functionId+""))) out.print("checked");%> <%if ("view".equalsIgnoreCase(userAction)) out.print ("disabled");%> name='<%="FUNCTION_ID," + functionId + "," + groupId + ",view"%>'> View &nbsp;&nbsp;&nbsp;&nbsp;
                <%}%>

                <%if (functionality.getModify() == true) {%>
                    <!-- Modified by Prabhanjan on 2nd Jan 2004 -->
                    <!-- <input type='checkbox' <%if ("true".equalsIgnoreCase ((String) modifyAccessMap.get (functionId+""))) out.print("checked");%> <%if ("view".equalsIgnoreCase(userAction)) out.print ("disabled");%> name='<%="FUNCTION_ID," + functionId + "," + groupId + ",modify"%>'> Modify &nbsp;&nbsp;&nbsp;&nbsp; -->
                    <% if (functionName.equals("Board Notifications") || (functionName.equals("Kit Notifications") || (functionName.equals("Chip Notifications")))) { %>
                        <input type='checkbox' class="txfield" <%if ("true".equalsIgnoreCase ((String) modifyAccessMap.get (functionId+""))) out.print("checked");%> <%if ("view".equalsIgnoreCase(userAction)) out.print ("disabled");%> name='<%="FUNCTION_ID," + functionId + "," + groupId + ",modify"%>'> Notify &nbsp;&nbsp;&nbsp;&nbsp;
                    <% } else { %>
                        <input type='checkbox' class="txfield" <%if ("true".equalsIgnoreCase ((String) modifyAccessMap.get (functionId+""))) out.print("checked");%> <%if ("view".equalsIgnoreCase(userAction)) out.print ("disabled");%> name='<%="FUNCTION_ID," + functionId + "," + groupId + ",modify"%>'> Modify &nbsp;&nbsp;&nbsp;&nbsp;
                    <% }  %>

                <%}%>

                <%if (functionality.getDelete() == true) {%>
                    <input type='checkbox' class="txfield" <%if ("true".equalsIgnoreCase ((String) deleteAccessMap.get (functionId+""))) out.print("checked");%> <%if ("view".equalsIgnoreCase(userAction)) out.print ("disabled");%> name='<%="FUNCTION_ID," + functionId + "," + groupId + ",delete"%>'> Delete &nbsp;&nbsp;&nbsp;&nbsp;
                <%}%>

                </font></td>
            </tr>
<%
        }   // for (int j=0; j<permissionsSiz.....
%>
	</table>


</div>
</td>
</tr>

<%
    }   //for (int i=0; i<userGroupSi....
}   //if (userGroup != nu....
%>

    <tr><td colspan='5'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tr>
    <%if (("modify".equalsIgnoreCase (userAction ) == false) && ("view".equalsIgnoreCase (userAction ) == false)) {%>
    <tr><td colspan='5'><font class="NArialL">
    <%if ( ( "saveUserAs".equalsIgnoreCase ( userAction ) == true ) || (  userAction  == null )  || "null".equalsIgnoreCase( userAction ) )
    { %>
        <% if( Boolean.valueOf ( request.getParameter("notifyUser") ) == Boolean.TRUE ){%>
        <input type="checkbox" name="notifyUser"  value='on'  checked class="txfield" >
        <%--<html:checkbox name='userSetupForm' property='notifyUser'/>--%>&nbsp;Notify User about the setup information</font>
     <%}else{%>
        <html:checkbox name='userSetupForm' property='notifyUser' styleClass="txfield"/>&nbsp;Notify User about the setup information</font>
       <%}%>
        <br><font class='NArialL'>Message to the user:</font><br>
        <%
           String msg = "";
           msg= (String)request.getParameter("userMsg");
           if( msg == null ){
               msg = "";
           }else{
               msg = msg.trim();
           }
        %>
         <TEXTAREA NAME="messageToUser" ROWS="4" COLS="60" align = "left" class="txfield">
         <%if( !"".equalsIgnoreCase( msg ) ){ out.print(msg.trim() ); } %>
         </TEXTAREA>
        <%--<html:textarea name='userSetupForm' property='messageToUser' rows='4' cols='60' styleClass='NArialL'/>--%>
    <%}else{%>

        <html:checkbox name='userSetupForm' property='notifyUser'/>&nbsp;Notify User about the setup information</font>
        <br><font class='NArialL'>Message to the user:</font><br>
        <TEXTAREA NAME="messageToUser" ROWS="4" COLS="60" class="txfield" align = "left">&nbsp;</TEXTAREA>
        <%--<html:textarea name='userSetupForm' property='messageToUser' rows='4' cols='60' styleClass='NArialL'/>--%>
        <%}%>
    </td></tr>
    <%}%>

</table>
<!-- GROUPS AND FUNCTIONALITY DISPLAY CODE ENDS HERE -->

	</td></tr>
	<tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tr>
	<tr><td colspan=5 align=center>
          <%--
            <%if ("modify".equalsIgnoreCase(userAction) == true){%>
            <a href="javascript:modifyUser()" onMouseOver="window.status='Click to Update User Information';return true" onMouseout="window.status='';return true" title="Click here to Update User Information">
            <%}
			 else if ("view".equalsIgnoreCase(userAction) == false){%>
            <a href="javascript:saveUser()" onMouseOver="window.status='Click to Save User Information';return true" onMouseout="window.status='';return true" title="Click here to Save User Information">
            <%}%>
            <img  border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" width="53" height="17"><%if ("view".equalsIgnoreCase(userAction) == false){%></a><%}%>
	        &nbsp;&nbsp;&nbsp;&nbsp;
            <%--modified  by varma(29 jun 2004)
            <a href="javascript:document.userSetupForm.reset();"><img src="<%=chipTracContext%>/jsp/includes/images/reset.gif" border='0' onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset"></a>&nbsp;&nbsp;&nbsp;&nbsp;
            <!--Sarada 0n 30th Sep 2003 To Modify Back button to show admin main page if we click on it -->
	        <a href="<%=chipTracContext%>/maintainUser.do"><img onMouseOver="window.status='Click to go Back';return true" onMouseout="window.status='';return true" title="Click here to go Back" border="0" src="<%=chipTracContext%>/jsp/includes/images/back.gif" width="39" height="17"></a></td>
            --%>
            <%--Modified by varma 16 jul 2004 to add reset button in modify and insert screens and removed save button in view screen --%>
            <logic:notEqual parameter="useraction" value="view" scope="request">
                <logic:equal parameter="useraction" value="modify" scope="request">
                   <a href="javascript:modifyUser()" onMouseOver="window.status='Click to Update User Information';return true" onMouseout="window.status='';return true" title="Click here to Update User Information">
                   <img  border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" width="53" height="17"></a>&nbsp;&nbsp;&nbsp;&nbsp;
                   <a href="javascript:document.userSetupForm.reset();"><img src="<%=chipTracContext%>/jsp/includes/images/reset.gif" border='0' onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset"></a>&nbsp;&nbsp;&nbsp;&nbsp;
                </logic:equal>
                <logic:notEqual parameter="useraction" value="modify" scope="request">
                   <a href="javascript:saveUser()" onMouseOver="window.status='Click to Save User Information';return true" onMouseout="window.status='';return true" title="Click here to Save User Information">
                   <img  border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" width="53" height="17"/></a>&nbsp;&nbsp;&nbsp;&nbsp;
                   <a href="javascript:document.userSetupForm.reset();"><img src="<%=chipTracContext%>/jsp/includes/images/reset.gif" border='0' onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset"></a>&nbsp;&nbsp;&nbsp;&nbsp;
                </logic:notEqual>
            </logic:notEqual>

            <a href="<%=chipTracContext%>/maintainUser.do"><img onMouseOver="window.status='Click to go Back';return true" onMouseout="window.status='';return true" title="Click here to go Back" border="0" src="<%=chipTracContext%>/jsp/includes/images/back.gif" width="39" height="17"></a></td>
    </tr>

    <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=40></td></tr>

  </table>

<!-- BODY ENDS HERE -->


<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>

<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->

</html:form>
<%if( "True".equals(valuee) && "false".equals(regionValue)){
%>
<script language="javascript">
	var userValue = document.userSetupForm.userId.value;
//alert(userValue);

var pa = document.getElementById("ErrorMessage");
var htmltext1  = "<li>  UserId '"+userValue+"' already exists, please enter another UserId ";

pa.insertAdjacentHTML('BeforeEnd',htmltext1);
</script>
<% }%>

</body>

</html:html>